import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {MaConfigForm, MaConfigQuery, MaConfigVO} from '@/api/infra/maConfig/types';

/**
 * 查询小程序配置列表
 * @param query
 * @returns {*}
 */

export const listMaConfig = (query?: MaConfigQuery): AxiosPromise<MaConfigVO[]> => {
  return request({
    url: '/infra/maConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小程序配置详细
 * @param configId
 */
export const getMaConfig = (configId: string | number): AxiosPromise<MaConfigVO> => {
  return request({
    url: '/infra/maConfig/' + configId,
    method: 'get'
  });
};

/**
 * 新增小程序配置
 * @param data
 */
export const addMaConfig = (data: MaConfigForm) => {
  return request({
    url: '/infra/maConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改小程序配置
 * @param data
 */
export const updateMaConfig = (data: MaConfigForm) => {
  return request({
    url: '/infra/maConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除小程序配置
 * @param configId
 */
export const delMaConfig = (configId: string | number | Array<string | number>) => {
  return request({
    url: '/infra/maConfig/' + configId,
    method: 'delete'
  });
};


/**
 * 查询小程序配置详细
 */
export const getTenantMaConfig = (): AxiosPromise<MaConfigVO> => {
  return request({
    url: '/infra/maConfig/tenant',
    method: 'get'
  });
};
